Annotations can be used by software program developers to associate arbitrary attributes with classes, methods, and fields. For instance, developers may inject annotations throughout a Java source code file to simplify software development. An Annotation Processing Tool (hereinafter referred to as “APT”) is invoked on the Java source code file so as to locate all annotations present in the source code, if any. The located annotations are then processed by the associated processors such that one processor owns only one annotation, and class files and/or new Java source files are generated. If processing an annotation has resulted in generating a new source file, APT is invoked recursively until the of invoking APT no longer results in generating a new source file. The default behavior of APT is to parse all source files even if only a single file changed. The only way APT does nothing is if all the class file timestamps are later than the source file timestamps. Thus, the reprocessing of annotations occurs every time a modification to the source file causes the time stamp of the source file to be later than the time stamp of the class file. More specifically, the latter cycle is repeated every time a modification is made to the Java source code irrespective of the type of the modification (e.g., adding or deleting a comment and/or space) or the extent of the modification to the source code or any of the annotations.
Several limitations can be associated with the invoking of APT each time the source is modified. One of such limitations is that the compilation cycle is unnecessarily increased because some of the annotation processors are unnecessary re-executed. For instance, annotations in the source code are reprocessed by the associated processors, and thus compiled, even though none of the annotations have been modified or affected, directly or indirectly by the changes. Alternatively, all the annotations are reprocessed even though modifications to the source code may have involved minimal changes maybe to one or few of the annotations. It should be considered that many annotations in the source file will not be affected by a large class of changes (implementation, comments, and whitespaces). Thus, most changes will not affect the annotations and will therefore not require running of the associated annotation processors which have an undetermined effect on the compilation speed. It should be appreciated that the reprocessing of unmodified or unaffected annotations increases compilation time, thus negatively affecting the software development cycle, reducing developer productivity, and wasting computing resources.
In view of the foregoing, a solution is needed for enhancing the software development process through reduction of compilation cycles by selectively limiting the annotations to be reprocessed when a modification is made to the source code or annotation.